package com.jzo2o.foundations.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.RegionPageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.RegionResDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IRegionService;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

@Validated
@RestController("operationServeController")
@RequestMapping("/operation/serve")
@Api(tags = "运营端 - 区域服务相关接口")
public class ServeController {

    @Resource
    private IServeService serveService;

    @GetMapping("/page")
    @ApiOperation("区域服务分页查询")
    public PageResult<ServeResDTO> page(ServePageQueryReqDTO dto) {
        return serveService.page(dto);
    }


    @PostMapping("/batch")
    @ApiOperation("区域服务批量新增")
    public void saveBatch(@RequestBody List<ServeUpsertReqDTO> dtoList){
        serveService.saveBatch(dtoList);
    }

    @PutMapping("/{id}")
    @ApiOperation("区域服务价格修改")
    public void updatePriceById(@PathVariable(name = "id")Long id,
                                @RequestParam(name = "price")BigDecimal price){
        serveService.updatePriceById(id,price);
    }

    @PutMapping("/onSale/{id}")
    @ApiOperation("区域服务上架")
    public void updateOnSaleStatusById(@PathVariable(name = "id")Long id){
        serveService.updateOnSaleStatusById(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("区域服务删除")
    public void updatePriceById(@PathVariable(name = "id")Long id){
        serveService.deleteById(id);
    }

    @PutMapping("/offSale/{id}")
    @ApiOperation("区域服务下架")
    public void updateOffSaleStatusById(@PathVariable(name = "id")Long id){
        serveService.updateOffSaleStatusById(id);
    }

    @PutMapping("/onHot/{id}")
    @ApiOperation("区域服务热门设置")
    public void updateOnHotById(@PathVariable(name = "id")Long id){
        serveService.updateOnHotById(id);
    }

    @PutMapping("/offHot/{id}")
    @ApiOperation("区域服务取消热门设置")
    public void updateOffHotById(@PathVariable(name = "id")Long id){
        serveService.updateOffHotById(id);
    }
}
